#include<bits/stdc++.h>
#define ll long long
#define db double
#define Si set<int>::iterator
using namespace std;
int const N=1e5+5;
db const del=1e-8;
ll read()
{
    char x=getchar();
    ll s=0,f=1;
    while(x<'0'||x>'9')
    {
        if(x=='-')f=-f;
        x=getchar();
    }
    while('0'<=x&&x<='9')s=s*10+x-'0',x=getchar();
    return s*f;
}
struct segment
{
    int l,r;
}a[N];
struct vehi
{
    db d,v,a;
}b[N];
int cnt,ans1,ans2;
db pos[N];
bool cmp(segment x,segment y)
{
    if(x.r==y.r)return x.l<y.l;
    return x.r<y.r;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);/**/
    int T;T=read();
    int n,m,L,i,p;
    db V;
    while(T--)
    {
        n=read();m=read();L=read();V=read();
        ans1=ans2=cnt=0;p=-1;
        for(i=1;i<=n;i++)
        {
            b[i].d=read();b[i].v=read();b[i].a=read();
        }
        for(i=1;i<=m;i++)
        {
            pos[i]=read();
        }
        for(i=1;i<=n;i++)
        {
            if(b[i].a>=0)
            {
                int l=1,r=m;
                while(l<r)
                {
                    int mid=(l+r)>>1;
                    if(pos[mid]+del<b[i].d)l=mid+1;
                    else r=mid;
                }
                if(pos[l]+del<b[i].d)continue;
                r=m;
                while(l<r)
                {
                    int mid=(l+r)>>1;
                    if(b[i].v*b[i].v+2.0*b[i].a*(pos[mid]-b[i].d)>V*V+del)r=mid;
                    else l=mid+1;
                }
                if(b[i].v*b[i].v+2.0*b[i].a*(pos[l]-b[i].d)>V*V+del)
                {
                    a[++cnt].l=l;a[cnt].r=m;ans1++;
                }
            }
            else
            {
                int l=1,r=m;
                while(l<r)
                {
                    int mid=(l+r)>>1;
                    if(pos[mid]+del<b[i].d)l=mid+1;
                    else r=mid;
                }
                if(pos[l]+del<b[i].d)continue;
                int l1=l;r=m;
                while(l<r)
                {
                    int mid=(l+r+1)>>1;
                    if(b[i].v*b[i].v+2.0*b[i].a*(pos[mid]-b[i].d)>0+del)l=mid;
                    else r=mid-1;
                }
                int r1=l;
                l=l1;r=r1;
                while(l<r)
                {
                    int mid=(l+r+1)>>1;
                    if(b[i].v*b[i].v+2.0*b[i].a*(pos[mid]-b[i].d)>V*V+del)l=mid;
                    else r=mid-1;
                }
                if(b[i].v*b[i].v+2.0*b[i].a*(pos[l]-b[i].d)>V*V+del)
                {
                    a[++cnt].l=l1;a[cnt].r=l;ans1++;
                }
            }
        }
        printf("%d ",ans1);
        sort(a+1,a+cnt+1,cmp);
        for(i=1;i<=cnt;i++)
        {
            if(a[i].l<=p&&p<=a[i].r)continue;
            p=a[i].r;ans2++;
        }
        printf("%d\n",m-ans2);
    }
    return 0;
}
